<% layout('/layout/default.html', {title: '字典管理', libs: ['dataGrid','icheck']}){ %>
<div class="main-content">
	<div class="card-header">
		<i class="fa fa-sitemap"></i> 字典管理
		<div class="header-tools float-right">
			<a href="#" class="btn btn-sm btn-secondary" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			<% if(hasPermi('sys:dict:edit')){ %>
			<a href="/sys/dict/form?sort=10" class="btn btn-sm btn-secondary btnTool" title="字典添加"><i class="fa fa-plus"></i> 新增</a>
			<% } %>
		</div>
	</div>
    <div class="container-fluid">
        <form id="searchForm" action="${ctx}/sys/dict/listAll" class="form-inline d-none">
            <div class="form-group">
                <label class="control-label">类型：</label>
                <div class="control-inline">
                    <#form:select path="type" name="type" value="type" data="${typeList}" class="form-control " />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">描述：</label>
                <div class="control-inline">
                    <input name="description" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary ">查询</button>
                <button id="reset" type="reset" class="btn btn-secondary ">重置</button>
            </div>
        </form>
        <table id="btGrid"></table>
    </div>
</div>
<% } %>
<script>
    $.fn.select2.defaults.set('width', '200px');
//初始化DataGrid对象
	$('#btGrid').BTGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{title:'键值', field:'value', width:50, align:"center", sortable:true},
			{title:'标签', field:'label', width:100, align:"center", sortable:true},
			{title:'类型', field:'type', width:100, align:"center", sortable:true},
			{title:'描述', field:'description', width:100, align:"center", sortable:true},
			{title:'排序', field:'sort', width:50, align:"center"},
			{title:'操作', field:'id', width:80, align:"center", formatter: function(val, row, index){
				var actions = [];
				<% if(hasPermi('sys:dict:edit')){ %>
					actions.push('<a href="/sys/dict/form?id='+row.id+'" class="btn btn-sm btn-success btnList" title="编辑字典信息"><i class="fa fa-pencil"></i></a>&nbsp&nbsp');
                    actions.push('<a href="/sys/dict/form?type='+row.type+'&description='+row.description+'&sort='+(row.sort+10)+'" class="btn btn-sm btn-primary btnList" title="添加键值"><i class="fa fa-plus-square"></i></a>&nbsp&nbsp');
					actions.push('<a href="${ctx}/sys/dict/delete?id='+row.id+'" class="btn btn-sm btn-danger btnList" title="删除字典" data-confirm="确认要删除字典信息吗?"><i class="fa fa-trash-o"></i></a>');

				<% } %>
				return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){
			
		}
	});
</script>

<script type="text/javascript">
    $('#reset').click(function(){
        $('#type').val(null).trigger("change");
    });

</script>